#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   log.py
@Time    :   2024/02/09 01:50:20
@Author  :   chakcy 
@Email   :   947105045@qq.com
@description   :   日志
'''

import logging
from datetime import datetime

# 日志初始化
def log_init(log_path:str, isDEBUG=False):
    fileName = datetime.now().strftime("%Y%m%d") + ".log"
    logging.basicConfig(
        level = isDEBUG and logging.DEBUG or logging.INFO,
        format = '%(asctime)s %(levelname)s %(message)s',
        handlers = [
            logging.FileHandler(f"{log_path}/{fileName}"),
            logging.StreamHandler()
        ]
    ) 

if __name__ == '__main__':
    logging.debug('这是一条调试信息')  
    logging.info('这是一条普通信息')  
    logging.warning('这是一条警告信息')  
    logging.error('这是一条错误信息')  
    logging.critical('这是一条严重错误信息')